{include file="public/layout" /}

<body>
<link rel="stylesheet" href="__SKIN__/css/page.css" media="all">

<div class="layui-fluid" id="LAY-component-layer-list">
    <div class="layui-card">
        <div class="head-oper layadmin-layer-demo">
            <div class="fr">
                <form action="{:url('Tags/index')}" method="get" onsubmit="layer_loading();">
                    <div class="fl mt5" >
                        <div class="layui-input-inline w240">
                            {$searchform.hidden|default=''}
                            <input type="text" name="keywords" id="keywords" value="{$Request.param.keywords}" placeholder="搜索名称" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-input-inline w50 mt5">
                        <button class="layui-btn input-btn-search" type="submit"><i class="layui-icon layui-icon-search"></i></button>
                    </div>
                </form>
            </div>
        </div>
        <div class="layui-card-body">
            <div class="layui-form layui-border-box layui-table-view house-table" lay-filter="demo" lay-id="admin-arctype" >
                <div class="layui-table-box">
                    <div class="layui-table-body " >
                        <table cellspacing="0" cellpadding="0" border="0" class="layui-table layui-form" style="width: 100%" lay-skin="line">
                            <thead >
                            <tr>
                                <th class="w40 tc">
                                    <div class="layui-table-cell w40 tc laytable-cell-checkbox">
                                        <input type="checkbox"  lay-filter="checkAll" class="checkAll"   lay-skin="primary" >
                                        <div class="layui-unselect layui-form-checkbox" lay-skin="primary"> <i class="layui-icon layui-icon-ok"></i></div>
                                    </div>
                                </th>
                                <th class="wauto"> <div class="layui-table-cell wauto"><span>标签名称</span></div></th>
                                <th class="w110 tc"> <div class="layui-table-cell w110 tc"><span>新增时间</span></div></th>
                                <th class="w100 tc"> <div class="layui-table-cell w100 tc"><span>操作</span></div></th>
                            </tr>
                            </thead>
                            <tbody>
                            {empty name="list"}
                            <tr>
                                <td class="no-data" align="center" axis="col0" colspan="4">
                                    <i class="fa fa-exclamation-circle"></i>没有符合条件的数据
                                </td>
                            </tr>
                            {else /}
                            {foreach name="list" item="vo" key="k" }
                            <tr>
                                <td>
                                    <div class="layui-table-cell w40 tc laytable-cell-checkbox">
                                        <input type="checkbox" name="ids[]" value="{$vo.id}" lay-filter="ids" lay-skin="primary">
                                    </div>
                                </td>
                                <td>
                                    <div class="layui-table-cell wauto" title=" ">
                                        {$vo.tag}
                                    </div>
                                </td>
                                <td>
                                    <div class="layui-table-cell w110 tc">
                                        {$vo.add_time|date='Y-m-d',###}
                                    </div>
                                </td>
                                <td>
                                    <div class="layui-table-cell w100 tc right-oper">
                                        {eq name="'Tags@del'|is_check_access" value="1"}
                                        <a class="layui-btn btn-edit customvar_edit"  data-url="{:url('Tags/del')}" data-id="{$vo.id}" data-type="Tags_del" >
                                         删除
                                        </a>
                                        {/eq}
                                    </div>
                                </td>
                            </tr>
                            {/foreach}
                            {/empty}
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="layui-table-page footer-oper">
                    <input type="checkbox" lay-filter="checkAll" class="checkAll" lay-skin="primary" >
                    <div class="nav-dropup">
                        <button class="layui-btn layui-btn-primary dropdown-bt" >批量操作<i class="layui-icon layui-icon-up"></i></button>
                        <div class="dropdown-menu">
                            {eq name="'Tags@del'|is_check_access" value="1"}
                            <a class="eju-event" href="javascript:;" data-type="batch_del" data-url="{:url('Tags/del')}">批量删除</a>
                            {/eq}
                            {eq name="'Tags@clearall'|is_check_access" value="1"}
                            <a class="eju-event"  href="javascript:;" data-type="clearall">一键清空</a>
                            {/eq}
                        </div>
                    </div>
                </div>
                <!--分页-->

            </div>
            {$pageStr}
        </div>
    </div>
</div>

<script>
    layui.config({
        base: '__SKIN__/' //静态资源所在路径
        ,version: '{$version}'
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table'], function(){
        var $ = layui.$
            ,form = layui.form
            ,table = layui.table;

        /* 触发事件 */
        var active = {
            Tags_del: function(){
                delfun(this);
            }
            ,batch_del: function(){
                batch_del(this,'ids');
            }
            ,clearall: function () {
                clearall();
            }
        };
        $('#LAY-component-layer-list .layui-btn,.eju-event').on('click', function(){
            var type = $(this).data('type');
            active[type] && active[type].call(this);
        });

        // 监听复选框全选
        form.on('checkbox(checkAll)', function(data){
            if (data.elem.checked) {
                $('.checkAll').attr('checked', true);
                $('input[name*=ids]').attr('checked', true);
            } else {
                $('.checkAll').attr('checked', false);
                $('input[name*=ids]').attr('checked', false);
            }
            form.render('checkbox');
        });

        // 监听每行复选框
        form.on('checkbox(ids)', function(data){
            if (data.elem.checked && $('input[name*=ids]:checked').length == $('input[name*=ids]').length) {
                $('.checkAll').attr('checked', true);
            } else {
                $('.checkAll').attr('checked', false);
            }
            form.render('checkbox');
        });
    });

    //清空所有标签
    function clearall()
    {
        // 删除按钮
        layer.confirm('此操作不可恢复，确认一键清空？', {
            title: false,
            btn: ['确定', '取消'] //按钮
        }, function () {
            var load = layer_loading();
            $.ajax({
                type: "POST",
                url: "{:url('Tags/clearall')}",
                data: {_ajax:1},
                dataType: 'json',
                success: function (res) {
                    layer.closeAll();
                    if(res.code == 1){
                        window.location.reload();
                    }else{
                        showErrorMsg(res.msg);
                    }
                },
                error:function(){
                    layer.closeAll();
                    showErrorAlert();
                }
            });
        });
    }
    $(".dropdown-bt").click(function(){
        $(".dropdown-menu").slideToggle(200);
        event.stopPropagation();
    })
    $(document).click(function(){
        $(".dropdown-menu").slideUp(200);
        event.stopPropagation();
    })
</script>
{include file="public/footer" /}
